<?php
/**********************
**arrays.inc
**Date Created: 4/13/2009
**Copyright 2009 Tomorrow Tech Industries
**Contact: RPITomorrowTech@gmail.com
**********************/

	require_once("private/user.inc");
	/*****************************************
	This File is soley for the use of array 
	storage.
	All files that use the arrays should 
	include arrays.php.
	*******************************************/
	
	function CreateArrays()
	{
		//Not sure if this will work inside the function.  Arrays may need to be initialized outside function.
		
		//Initialize the arrays to hold lists of Users, intellistrips, etc
		$users = array("" => "");  //Creates array with key = name, value = User object
		$intellistrips = array("" => "");  //Creates array with key = roomID, value = Intellistrip object
			//It is important to remember that after their creation, these arrays do not use the database at all.
			//And durring the creation, it only reads from the databse, never writes to it.
			//So, after creation, the arrays are completely standalone.  Therefore, whenever the database is updated,
			//these arrays need to be updated as well.  This should take place in the outer file, not the Object Class.
			//For example, when a new strip is added, it gets added to the database, and inside updatestrips.php, the 
			//intellistrips array will be updated, not in the Intellistrip class or its helper functions.
		//test to see if this method gets called.
		//echo "<br>Inside CreateArrays<br>"; 
		//Add more as we develop them
		
		$users = LoadUsers();
		//$intellistrips = LoadIntellistrips();
		return;
	}
	
	function LoadUsers()
	{
		$numberOfUsers = getNumberOfUsers();
			//Now that getNumberOfUsers has been called, when this number is needed in other files or functions,
			//can just make: global $NumberOfUsers;
		$tempUser = new User("hello", "hello", "hello", 0, 4);  //Creates an empty user.   No database interaction here.  The 4 indicates that this data not be added to the database.
		$names = array(0 => "a");  //Creates an array of names from the database.  Key = int, value = name.  This gets filled below.
		$usernames = array(0 => "b");  //Creates an array of usernames from the database.  Key = int, value = username.  This gets filled below.
		$accessGroups = array(0 => "c");  //Creates an array of accessGroups from the database.  Key = int, value = accessGroup.  This gets filled below.
		$passwords = array(0 => "5");  //Creates an array of passwords from the database.  Key = int, value = password.  This gets filled below.
		fillObject($names, $usernames, $passwords, $accessGroups); //Fills these arrays with info from the database.
		//print_r($names);
		for($count = 0; $count < $numberOfUsers; $count++)  //Not sure if syntax is correct.
		{
			//Create a user object with info from fillObject();
			$tempUser->setUserName($usernames[$count], 4);  //Updates myUserName inside the tempUser class.  The 4 means not to update database.
			$tempUser->setName($names[$count], 4);  //Updates myName inside the tempUser class.  The 4 means not to update database.
			$tempUser->setPassword($passwords[$count], 4);  //Updates myPassword inside the tempUser class.  The 4 means not to update database.
			$tempUser->setAccessGroup($accessGroups[$count], 4);  //Updates myAccessGroup inside the tempUser class.  The 4 means not to update database.
			//$tempUser->PrintUser();
			//echo $tempUser->getName();
			//Push the tempUser object into the user array.
			$users[$usernames[$count]] = $tempUser;
		}
		//test to see if this method gets called
		//echo "<br>Inside LoadUsers<br>";
		return $users;
	}
	
	function PrintUsers($users)
	{
		$tempUser = new User("", "", "", 0, 4);
		for($count = 0; $count < 2; $count++)
		{
			$tempUser = $users["Sam"];
			$tempUser->PrintUser();
			echo "<br>";
		}
	}
	
	
	
	
?>
